package com.linkoog.devtools.intellij.ui.file_browse;

import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextComponentAccessor;
import com.linkoog.devtools.intellij.ui.button.TextFieldWithBrowseButton;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class TextBrowseFolderListener extends BrowseFolderActionListener<JTextField> {
    public TextBrowseFolderListener(@NotNull FileChooserDescriptor fileChooserDescriptor) {
        this(fileChooserDescriptor, null);
    }

    public TextBrowseFolderListener(@NotNull FileChooserDescriptor fileChooserDescriptor, @Nullable Project project) {
        super(null, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    }

    public void setOwnerComponent(@NotNull TextFieldWithBrowseButton component) {
        myTextComponent = component.getChildComponent();
    }

    public FileChooserDescriptor getFileChooserDescriptor() {
        return myFileChooserDescriptor;
    }
}
